<?php 
require_once "includes/DB.class.php";

    $principal =  "current";
    $nosotros =  "";
    $reservaciones =  "" ;
    $torneos =  "" ;
    $galeria =  "" ;
    $contacto =  ""; 
?>


<!DOCTYPE html>
<title>PaintBall Warriors</title>
<html lang="en">
<head>
  <title>Pa&aacute;ina Principal</title>
  <meta charset="utf-8">
  <meta name="description" content="Your description">
  <meta name="keywords" content="Your keywords">
  <meta name="author" content="Your name">
  <link rel="stylesheet" href="../css/reset.css" type="text/css" media="all">
  <link rel="stylesheet" href="../css/grid.css" type="text/css" media="all">
  <link rel="stylesheet" href="../css/style.css" type="text/css" media="all">
   
  <!-- styles for prettyPhoto -->
  <link rel="stylesheet" href="../css/prettyPhoto.css" type="text/css" media="all">
  
  <script type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
  <script type="text/javascript" src="../js/script.js"></script>
  <script type="text/javascript" src="../js/cufon-yui.js"></script>
  <script type="text/javascript" src="../js/flashobject.js"></script>
  <script type="text/javascript" src="../js/Bebas_400.font.js"></script>
  <script type="text/javascript" src="../js/cufon-replace.js"></script>

  <!--[if lt IE 9]>
  	<script type="text/javascript" src="js/html5.js"></script>
  <![endif]-->
  <!--[if lt IE 7]>
	<script type="text/javascript" src="http://info.template-help.com/files/ie6_warning/ie6_script_other.js"></script>
  <![endif]-->
</head>

<body>	
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<!--
<script type='text/javascript'>
  //<![CDATA[
    window.fbAsyncInit = function() {
      FB.init({appId: '130300123790700', status: true, cookie: true, xfbml: true});
    };
    (function() {
      var e = document.createElement('script'); e.async = true;
      e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
      document.getElementById('fb-root').appendChild(e);
    }());
  //]]>
</script>
-->
    
	<header>
		<div class="container_12">
			<div class="extra-wrap">
				<div class="grid_12">
					<div class="extra-wrap">
						<div class="grid_6 alpha omega">
							<div class="logo">
								<a href="main">Paintball Deporte y Recreaci&oacute;nes</a>
							</div>
						</div>
                                                <?php include "includes/header.php"; ?>
						<div class="clear"></div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
	</header>
	<section id="content">
		<div class="container_12">
			<div class="extra-wrap">
				<div class="grid_12">
					<div class="faded-indent">
						<div id="head">
							<div  class="aligncenter">
								<a href="http://www.adobe.com/go/EN_US-H-GET-FLASH"><img src="http://www.adobe.com/images/shared/download_buttons/get_adobe_flash_player.png" alt=""/></a>
							</div>
						</div>
						<script type="text/javascript">
							var fo = new FlashObject("../flash/header-cs3.swf", "head", "1100", "566", "10.0.0", "");
							fo.addParam("quality", "high");
							fo.addParam("wmode", "transparent");
							fo.write("head");
						</script>
					</div>
                                    
    <div class="indent">
            <div class="main-divider">
                    <div class="wrapper main-divider1">
                            <article class="grid_4 alpha">
                                    <div class="col-indent">
                                            <h1 class="h1-pad">noticias</h1>

                                            <!-- Noticias  -->
                                            <?php

                                                for($i=0; $i < sizeOf( $noticias ) ; $i++){
                                                    echo "<strong class=\"date\">" . $noticias[$i][3] . "</strong>";
                                                    echo "<div>";
                                                    echo "<h6>" . $noticias[$i][1] . "</h6>";
                                                    echo $noticias[$i][2] . "</div>";
                                                }
                                                
                                                //echo "<a href=\"more.html\" class=\"button1 button1-margin\"><strong>Leer Mas</strong></a>";
                                            ?>


                                    </div>
                            </article>
                            <article class="grid_4">
                                    <div class="col-indent">
                                        <!--<fb:activity site="http://www.paintball-warriors.com" width="280" height="315"></fb:activity>-->
                                        <div class="fb-comments" data-href="http://www.paintball-warriors.com" data-width="280" data-num-posts="2"></div>
                                    </div>
                            </article>
                            <article class="grid_4 omega">
                                    <div class="col-indent">
                                            <h1 class="h1-pad">reservaciones</h1>
                                            <div class="slider-indent">
                                                    <div id="slider">
                                                            <?php

                                                            //This gets today's date 
                                                            $date =time () ; 

                                                            //This puts the day, month, and year in seperate variables 
                                                            $day = date('d', $date) ; 
                                                            $month = date('m', $date) ; 
                                                            $year = date('Y', $date) ;

                                                            //Here we generate the first day of the month 
                                                            $first_day = mktime(0,0,0,$month, 1, $year) ; 

                                                            //This gets us the month name 
                                                            $title = date('F', $first_day) ; 

                                                            //Here we find out what day of the week the first day of the month falls on 
                                                            $day_of_week = date('D', $first_day) ; 

                                                            //Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
                                                            switch($day_of_week){ 

                                                                    case "Sun": $blank = 0; break; 
                                                                    case "Mon": $blank = 1; break; 
                                                                    case "Tue": $blank = 2; break; 
                                                                    case "Wed": $blank = 3; break; 
                                                                    case "Thu": $blank = 4; break; 
                                                                    case "Fri": $blank = 5; break; 
                                                                    case "Sat": $blank = 6; break; 

                                                            }

                                                            //We then determine how many days are in the current month
                                                            $days_in_month = cal_days_in_month(0, $month, $year) ; 
                                                            ?>

                                                            <div>
                                                                    <h6 class="h6-pad"><?php 
                                                                                            setlocale(LC_TIME, 'spanish');
                                                                                            echo strftime("%B",mktime(0, 0, 0, $month, 1, 2000))  . "&nbsp;" . $year; ?></h6>
                                                                    <table class="calendar none1">
                                                                            <thead>
                                                                                    <tr>
                                                                                            <th>D</th>
                                                                                            <th>L</th>
                                                                                            <th>K</th>
                                                                                            <th>M</th>
                                                                                            <th>J</th>
                                                                                            <th>V</th>
                                                                                            <th>S</th>
                                                                                    </tr>
                                                                            </thead>
                                                                    </table>
                                                                    <table class="calendar">
                                                                            <tbody>

            <?php

                    $day_count = 1;
                    echo "<tr>";

                    //first we take care of those blank days

                     while ( $blank > 0 ) { 

                            echo "<td></td>"; 
                            $blank = $blank-1; 
                            $day_count++;

                    } 

                    //sets the first day of the month to 1 

                    $day_num = 1;

                    //count up the days, untill we've done all of them in the month
                    
                    while ( $day_num <= $days_in_month ) { 
                                    $habil = true;
                                    $halfFull = false;
                                    $fecha = $year .  "-" . $month . "-" . $day_num;

                                    if($day_count == 1  ){
                                        $habil = false;
                                    }
                                    
                                    $db = DB::Instance();
                                    $sql = "SELECT count(*) as reservas FROM `reservas` WHERE fecha = '$fecha' and estado = 'Confirmada'";
                                    
                                    $data = $db->query($sql);

                                    $reservas = $data->fetchAll();
                                    switch ( $reservas[0]["reservas"] ){
                                        case 0:
                                            break;
                                        case 1:
                                        case 2:
                                            $halfFull = true;
                                            break;
                                        case 3;
                                            $habil = false;
                                            break;
                                    }
                                    if($habil){
                                       if($halfFull){
                                            echo "<td class=\"halfReservation\"><a href=\"reservacion?fecha=$fecha\" >" . $day_num . "</a></td>"; 
                                       } else{
                                            echo "<td><a href=\"reservacion?fecha=$fecha\" >" . $day_num . "</a></td>"; 
                                       }
                                    } else {
                                        echo "<td class=\"active normaltip\" title=\"No hay Disponibilidad\">" . $day_num . "</td>"; 
                                    }
                                    $day_num++; 
                                    $day_count++;

                                    //Make sure we start a new row every week
                                    if ($day_count > 7){
                                                    echo "</tr><tr>";
                                                    $day_count = 1;
                                    }
                    } 
                    //Finaly we finish out the table with some blank details if needed

                    while ( $day_count >1 && $day_count <=7 )  { 
                            echo "<td></td>"; 
                            $day_count++; 
                    } 

                    echo "</tr>"; 
            ?>


                                                                            </tbody>
                                                                    </table>
                                                            </div>

                                                    </div>
                                                    <a href="#" class="next1"><img src="../images/next-link1.png" alt="" /></a>
                                                    <a href="#" class="prev1"><img src="../images/prev-link1.png" alt="" /></a>
                                            </div>
                                    </div>
                            </article>
                    </div>
            </div>
    </div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
	</section>
        <?php include "includes/footer.php" ?>

    <script type="text/javascript"> Cufon.now(); </script>


</body>
</html>
